<template>
  <div class="logout">
    <div class="logout-loading">
      <van-loading type="spinner" size="42px" text-size="13px;" vertical
        >加载中...</van-loading
      >
    </div>
  </div>
</template>

<script>
export default {
  created() {
    this.initData();
  },
  methods: {
    initData() {
      let url = location.href.split("?");
      let urlParam = url.length > 1 ? url[1] : "";
      console.log("params", urlParam);
      this.analyze(urlParam);
    },
    async analyze(data) {
      let res = await this.api.analysisData(data);
      if (!res.ok) {
        this.$dialog.alert({
          message: res.message
        });
        return;
      }
      if (res) {
        if (res.code === "40015") {
          this.$dialog
            .confirm({
              message: res.message,
              showCancelButton: false
            })
            .then(() => {
              this.$router.replace("/code/mine/setting");
            });
        } else {
          location.href = "yi-code://home";
        }
      }
    }
  }
};
</script>

<style lang="less" scoped>
.logout-loading {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -40%);
}
</style>
